import {getParentVip, getOrder, getOrderList, getChaegeMessage, 
    getResidualFlowAndResidualMinute, getPayStutus, addOrder,continueToPay, checkIsGiveStudentDevice,
    getStudentDevice} from '@/api/vipApi'
const vip = {
    namespaced: true,
    state: {
        userData:{},
        orderDetail: '',
        charge: localStorage.charge ? JSON.parse(localStorage.charge) : '',
        packages: localStorage.packages ? JSON.parse(localStorage.packages) : '',
    },
    getters: {

    },
    mutations: {
        SET_USERINFO(state,params){
            state.userData = params
        },
        setCharge (state, val) {
            state.charge = val
            localStorage.charge = JSON.stringify(val)
        },
        setPackages (state, val) {
            state.packages = val
            localStorage.packages = JSON.stringify(val)
        }
    },
    actions: {
        GetParentVip ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                getParentVip(params).then(res => {
                    resolve(res)
                })
            })
        },
        GetOrder ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                getOrder(params).then(res => {
                    resolve(res)
                })
            })
        },
        GetOrderList ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
              getOrderList(params).then(res => {
                    resolve(res)
                })
            })
        },
        GetChaegeMessage ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
              getChaegeMessage(params).then(res => {
                    resolve(res)
                })
            })
        },
        GetResidualFlowAndResidualMinute ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
              getResidualFlowAndResidualMinute(params).then(res => {
                    resolve(res)
                })
            })
        },
        GetPayStutus ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
              getPayStutus(params).then(res => {
                    resolve(res)
                })
            })
        },
        AddOrder ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                addOrder(params).then(res => {
                    resolve(res)
                })
            })
        },
        ContinueToPay ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                continueToPay(params).then(res => {
                    resolve(res)
                })
            })
        },
        CheckIsGiveStudentDevice ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                checkIsGiveStudentDevice(params).then(res => {
                    resolve(res)
                })
            })
        },
        GetStudentDevice ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                getStudentDevice(params).then(res => {
                    resolve(res)
                })
            })
        }
    }
}
export default vip
